home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 May: Tool Chest / Dev.CD May 98 TC.toast / Tool Chest / Development Kits / HyperCard Related / APDA HyperCard Toolkits / HyperCard CTB Toolkit 1.0b2 / Source Code / CTBTool.p < prev    next >
Encoding:
Text File  |  1995-02-07  |  1.8 KB  |  75 lines  |  [TEXT/MPS ]

  1. (*
  2.     CTBTool([type]) -- Return the current tool for the type of tool indicated ("connection" (default),
  3.         "terminal", or "file transfer").
  4.  
  5.     To compile and link this file using Macintosh Programmer's Workshop,
  6.  
  7.         pascal -w CTBTool.p
  8.         link -m ENTRYPOINT -o HyperCommands -rt XFCN=2755 -sn Main=CTBTool ∂
  9.             CTBTool.p.o "{MPW}"Libraries:interface.o "{MPW}"Libraries:Libraries:HyperXLib.o
  10.  
  11.     © Copyright 1990 by Apple Computer, Inc.
  12.  
  13.     Initial coding 2/90 by Harry R. Chesley.
  14. *)
  15.  
  16. {$R-}
  17.  
  18. {$S CTBTool }     { Segment name must be the same as the command name. }
  19.  
  20. unit DummyUnit;
  21.  
  22. interface
  23.  
  24. uses MemTypes, QuickDraw, OSIntf, ToolIntf, CTBUtils, FTIntf, CMIntf, TMIntf, CRMIntf, HyperXCmd;
  25.  
  26. procedure EntryPoint(paramPtr: XCmdPtr);
  27.     
  28. implementation
  29.  
  30. procedure CTBTool(paramPtr: XCmdPtr); forward;
  31.  
  32. procedure EntryPoint(paramPtr: XCmdPtr);
  33.  
  34.     begin
  35.         CTBTool(paramPtr);
  36.     end;
  37.  
  38. procedure CTBTool(paramPtr: XCmdPtr);
  39.  
  40.     {$I CTBUtil.inc}
  41.  
  42.     var tt: ToolType;
  43.         s: Str255;
  44.  
  45.     procedure Fail(errMsg: Str255); { set theResult and quit }
  46.         begin
  47.             paramPtr^.returnValue := PasToZero(paramPtr,errMsg);
  48.             exit(CTBTool);
  49.         end;
  50.  
  51.     begin
  52.         { Check the parameter count. }
  53.         if paramPtr^.paramCount > 1 then Fail('Invalid parameter count');
  54.  
  55.         { Figure out what kind of tool we want info on. }
  56.         if not ParmPresent(1) then tt := connectionTool
  57.         else tt := GetToolTypeParm(1);
  58.  
  59.         { Make sure the Comm Toolbox is here. }
  60.         CTBReady;
  61.  
  62.         { Get the tool name string. }
  63.         s := '';
  64.         case tt of
  65.             connectionTool: if Globals^^.connHand <> nil then CMGetToolName(Globals^^.connHand^^.procID,s);
  66.             terminalTool: if Globals^^.termHand <> nil then TMGetToolName(Globals^^.termHand^^.procID,s);
  67.             fileTransferTool: if Globals^^.FTHand <> nil then FTGetToolName(Globals^^.FTHand^^.procID,s);
  68.             end;
  69.  
  70.         { Return it. }
  71.         if s <> '' then paramPtr^.returnValue := PasToZero(paramPtr,s)
  72.     end;
  73.  
  74. end.
  75.